#ifndef _EKEKO_COMMON_H_
#define _EKEKO_COMMON_H_

#include <Ecore.h>
#include <Enesim.h>
#include <Eix.h>

/* the server path */
#define EKEKO_COMMON_SERVER_PATH "/tmp/ekeko"

/* define the message structs */
typedef struct _Ekeko_Msg_Image_Free
{
	uint32_t context_id;
	uint32_t id;
} Ekeko_Msg_Image_Free;

typedef struct _Ekeko_Msg_Image_Load
{
	uint32_t context_id;
	char *file;
} Ekeko_Msg_Image_Load;

typedef struct _Ekeko_Msg_Image_Load_Reply
{
	uint32_t id;
	uint32_t w;
	uint32_t h;
	uint32_t fmt;
	uint32_t offset;
} Ekeko_Msg_Image_Load_Reply;

typedef struct _Ekeko_Msg_Context_Free
{
	uint32_t id;
} Ekeko_Msg_Context_Free;

typedef struct _Ekeko_Msg_Context_Get
{
	uint32_t size;
	char *name;
} Ekeko_Msg_Context_Get;

/* This message depends on the platform, given that the values
 * depend on the shm backend used
 */
typedef struct _Ekeko_Msg_Context_Get_Reply
{
	uint32_t id;
	uint32_t size;
	char *name;
} Ekeko_Msg_Context_Get_Reply;

/* define the message handlers */
extern Eix_Message * EKEKO_MSG_CONTEXT_GET;
extern Eix_Message * EKEKO_MSG_CONTEXT_GET_REPLY;
extern Eix_Message * EKEKO_MSG_CONTEXT_FREE;
extern Eix_Message * EKEKO_MSG_IMAGE_LOAD;
extern Eix_Message * EKEKO_MSG_IMAGE_LOAD_REPLY;
extern Eix_Message * EKEKO_MSG_IMAGE_FREE;

void ekeko_common_message_init(void);
void ekeko_common_message_shutdown(void);


/* The ecore wrapper */
void ekeko_common_ecore_unix_udp_server_loopize(Eix_Server *s);
void ekeko_common_ecore_unix_udp_server_unloopize(Eix_Server *s);
void ekeko_common_ecore_unix_udp_client_loopize(Eix_Client *c);
void ekeko_common_ecore_unix_udp_client_unloopize(Eix_Client *c);

#endif
